﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Flowertwig.Utils.Entities
{
    public class PropertyItems<TKey, TValue> : IEnumerable<SerializableKeyValuePair<TKey, TValue>>
    {
        public SortedList<TKey, TValue> _internalList;

        public PropertyItems(ref SortedList<TKey, TValue> internalList)
        {
            _internalList = internalList;
        }

        #region IEnumerable<FlowKeyValuePair<TKey,TValue>> Members
        public void Add(Object obj)
        {
            var flow = obj as SerializableKeyValuePair<TKey, TValue>;
            if (flow == null)
                return;
            _internalList.Add(flow.Key, flow.Value);
        }

        public IEnumerator<SerializableKeyValuePair<TKey, TValue>> GetEnumerator()
        {
            return new KeyValueEnumerator<TKey, TValue>(_internalList.GetEnumerator());
        }

        #endregion

        #region IEnumerable Members

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        #endregion

    }
}
